<extend name="Base/common"/>
<block name="TITLE"><title>超人app推送助手</title></block>

<block name="body" >
  <div class="bar bar-header bar-stable">
    <h1 class="title">这样的天气,给超人们发个推送,打打气吧</h1>
  </div>
  <ion-content class="has-header padding" ng-controller="PushController">
    <div class="list">
      <label class="item item-input">
        <textarea placeholder="输入推送内容,大约100字左右,多了可能发不出去~" ng-model="pushContent" rows="5"></textarea>
      </label>

      <button class="button-block button button-calm" ng-click="send()">点击发送</button>
    </div>
  </ion-content>

</block>

<block name="script">
<script type="text/javascript">
  var apps = angular.module('gr-apps', ['ionic','ngApi']);
  var CONST_APP_KEYS = {mode:'PRODUCT',appkey:'45883198abcdc110',masterKey:'1b7e5703602b6fce1cae7364ac0f2249'};//product
  apps.run(function($ae){
    $ae.init(CONST_APP_KEYS);
  });
  apps.controller('PushController',function($scope,$ae){
    $scope.send = function(){
      if(!confirm('是否确认发送该消息?')) return;
      var func = new $ae.Function('api.push.boardcast');
      func.invoke({content:$scope.pushContent}).then(function(data){
          alert('发送成功');
      }).catch(function(err){
        console.log(err);
          alert('发送失败');
      });
    };
  })
</script>

</block>
